package com.liu.test;

import com.liu.dao.INovelDao;
import com.liu.dao.IUserDao;
import com.liu.dao.impl.NovelDaoImpl;
import com.liu.dao.impl.UserDaoImpl;
import com.liu.pojo.Novel;
import com.liu.pojo.User;
import com.liu.util.LoggerFactory;
import org.junit.BeforeClass;
import org.junit.Test;

import java.sql.SQLException;
import java.sql.Timestamp;

import static org.junit.Assert.assertTrue;

public class DaoTestCase implements LoggerFactory {
	
	IUserDao userDao = new UserDaoImpl();

	INovelDao novelDao = new NovelDaoImpl();

	static User user = new User();

	static Novel novel = new Novel();

	static Timestamp timestamp = new Timestamp(System.currentTimeMillis());


	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		
		user.setUser_name("admin2");
		user.setPwd("123456");
		user.setEmail("t@a.com");

		novel.setUser_id(1);
		novel.setTitle("ttt");
		novel.setAuthor_name("a1");
		novel.setCate_id(1);
		novel.setNtype(1);
		novel.setProgress(0);
		novel.setPush_time(timestamp);
		novel.setLast_update(timestamp);
		novel.setContent("content");
		novel.setDown_count(22);
		novel.setRead_count(21);
		novel.setState(1);
		novel.setIs_recommend(0);

		logger.info("Starging test.");
	}

	@Test
	public void testAssert() throws SQLException {

//		assertTrue(userDao.save(user) == 1);
		
//		assertEquals(userDao.queryByUsername("admin").getUser_name(), "admin");

		assertTrue(novelDao.save(novel) == 1);


	}

	@Test
	public void testResult() throws SQLException {

//		novelDao.queryListByUserid(1).forEach(System.out::println);

	}

}
